package com.ruoyi.system.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.common.core.text.Convert;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.system.domain.WebUserRecommendAward;
import com.ruoyi.system.mapper.WebUserRecommendAwardMapper;
import com.ruoyi.system.service.IWebUserRecommendAwardService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Arrays;
import java.util.List;
import java.util.Map;

/**
 * 用户推荐奖励Service业务层处理
 * 
 * @author wsliupan@126.com
 * @date 2021-05-30
 */
@Service
public class WebUserRecommendAwardServiceImpl extends ServiceImpl<WebUserRecommendAwardMapper, WebUserRecommendAward> implements IWebUserRecommendAwardService
{
    @Autowired
    private WebUserRecommendAwardMapper webUserRecommendAwardMapper;

    /**
     * 查询用户推荐奖励
     * 
     * @param id 用户推荐奖励ID
     * @return 用户推荐奖励
     */
    @Override
    public WebUserRecommendAward selectWebUserRecommendAwardById(Long id)
    {
        return webUserRecommendAwardMapper.selectWebUserRecommendAwardById(id);
    }

    /**
     * 查询用户推荐奖励列表
     * 
     * @param webUserRecommendAward 用户推荐奖励
     * @return 用户推荐奖励
     */
    @Override
    public List<WebUserRecommendAward> selectWebUserRecommendAwardList(WebUserRecommendAward webUserRecommendAward)
    {
        return webUserRecommendAwardMapper.selectWebUserRecommendAwardList(webUserRecommendAward);
    }

    /**
     * 新增用户推荐奖励
     * 
     * @param webUserRecommendAward 用户推荐奖励
     * @return 结果
     */
    @Override
    public int insertWebUserRecommendAward(WebUserRecommendAward webUserRecommendAward)
    {
        webUserRecommendAward.setCreateTime(DateUtils.getNowDate());
        return webUserRecommendAwardMapper.insertWebUserRecommendAward(webUserRecommendAward);
    }

    /**
     * 修改用户推荐奖励
     * 
     * @param webUserRecommendAward 用户推荐奖励
     * @return 结果
     */
    @Override
    public boolean updateWebUserRecommendAward(WebUserRecommendAward webUserRecommendAward)
    {
        //webUserRecommendAward.setUpdateTime(DateUtils.getNowDate());
        //return webUserRecommendAwardMapper.updateWebUserRecommendAward(webUserRecommendAward);
        return this.saveOrUpdate(webUserRecommendAward);
    }

    /**
     * 删除用户推荐奖励对象
     * 
     * @param ids 需要删除的数据ID
     * @return 结果
     */
    @Override
    public boolean deleteWebUserRecommendAwardByIds(String ids)
    {
        //return webUserRecommendAwardMapper.deleteWebUserRecommendAwardByIds(Convert.toStrArray(ids));
        return this.removeByIds(Arrays.asList(Convert.toStrArray(ids)));
    }

    /**
     * 删除用户推荐奖励信息
     * 
     * @param id 用户推荐奖励ID
     * @return 结果
     */
    @Override
    public boolean deleteWebUserRecommendAwardById(Long id)
    {
        //return webUserRecommendAwardMapper.deleteWebUserRecommendAwardById(id);
        return this.removeById(id);
    }

    /**
     * 查询用户的推广记录
     * @param userId
     * @return
     */
    @Override
    public List<Map<String,Object>> selectRecommendList(Integer userId){
        return webUserRecommendAwardMapper.selectRecommendList(userId);
    }
}
